package com.ruoyi.picking_detail.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.picking_detail.domain.ErpMaterialIssueDetail;
import com.ruoyi.picking_detail.service.IErpMaterialIssueDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生产领料子Controller
 * 
 * @author ruoyi
 * @date 2025-07-18
 */
@RestController
@RequestMapping("/picking_detail/picking_detail")
public class ErpMaterialIssueDetailController extends BaseController
{
    @Autowired
    private IErpMaterialIssueDetailService erpMaterialIssueDetailService;

    /**
     * 查询生产领料子列表
     */
    @PreAuthorize("@ss.hasPermi('picking_detail:picking_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpMaterialIssueDetail erpMaterialIssueDetail)
    {
        startPage();
        List<ErpMaterialIssueDetail> list = erpMaterialIssueDetailService.selectErpMaterialIssueDetailList(erpMaterialIssueDetail);
        return getDataTable(list);
    }

    /**
     * 导出生产领料子列表
     */
    @PreAuthorize("@ss.hasPermi('picking_detail:picking_detail:export')")
    @Log(title = "生产领料子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpMaterialIssueDetail erpMaterialIssueDetail)
    {
        List<ErpMaterialIssueDetail> list = erpMaterialIssueDetailService.selectErpMaterialIssueDetailList(erpMaterialIssueDetail);
        ExcelUtil<ErpMaterialIssueDetail> util = new ExcelUtil<ErpMaterialIssueDetail>(ErpMaterialIssueDetail.class);
        util.exportExcel(response, list, "生产领料子数据");
    }

    /**
     * 获取生产领料子详细信息
     */
    @PreAuthorize("@ss.hasPermi('picking_detail:picking_detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(erpMaterialIssueDetailService.selectErpMaterialIssueDetailById(id));
    }

    /**
     * 新增生产领料子
     */
    @PreAuthorize("@ss.hasPermi('picking_detail:picking_detail:add')")
    @Log(title = "生产领料子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpMaterialIssueDetail erpMaterialIssueDetail)
    {
        return toAjax(erpMaterialIssueDetailService.insertErpMaterialIssueDetail(erpMaterialIssueDetail));
    }

    /**
     * 修改生产领料子
     */
    @PreAuthorize("@ss.hasPermi('picking_detail:picking_detail:edit')")
    @Log(title = "生产领料子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpMaterialIssueDetail erpMaterialIssueDetail)
    {
        return toAjax(erpMaterialIssueDetailService.updateErpMaterialIssueDetail(erpMaterialIssueDetail));
    }

    /**
     * 删除生产领料子
     */
    @PreAuthorize("@ss.hasPermi('picking_detail:picking_detail:remove')")
    @Log(title = "生产领料子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(erpMaterialIssueDetailService.deleteErpMaterialIssueDetailByIds(ids));
    }
}
